<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('电子名片预授信记录列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>机构名称：</label>
                            <input name="deptId" type="hidden" id="treeId"/>
                            <input name="deptName" onclick="selectDeptTree()" id="treeName" type="text"
                                   placeholder="请选择归属机构" autocomplete="off">
                        </li>
                        <li>
                            <label>营销人员：</label>
                            <input type="text" name="userName"/>
                        </li>
                        <li>
                            <label>客户类型：</label>
                            <select name="custType" th:with="type=${@dict.getType('ecard_cust_type')}"
                                    id="custType">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>姓名：</label>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <label>手机号码：</label>
                            <input type="text" name="phone"/>
                        </li>
                        <li>
                            <label>身份证号：</label>
                            <input type="text" name="cardNum"/>
                        </li>
                        <li>
                            <label>状态：</label>
                            <select name="sts" th:with="type=${@dict.getType('ecard_pre_credit_sts')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li class="select-date">
                            <label>创建日期： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" readonly
                                   name="params[startDate]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" readonly
                                   name="params[endDate]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="inquire()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ecard:prior:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="ecard:prior:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="ecard:prior:remove">
                <i class="fa fa-remove"></i> 删除
            </a>-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ecard:prior:export">
                <i class="fa fa-download"></i> 导出
            </a>
            <a class="btn btn-primary multiple disabled" onclick="handOver()" style="visibility: hidden;" id="handOver"
               shiro:hasPermission="ecard:prior:handOver">
                <i class="fa fa-exchange"></i> 转交
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var custTypeDatas = [[${@dict.getType('ecard_cust_type')}]];
    var stsDatas = [[${@dict.getType('ecard_pre_credit_sts')}]];
    var prefix = ctx + "ecard/priorCredit";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "电子名片预授信记录",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'custType',
                    title: '客户类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(custTypeDatas, value);
                    }
                },
                {
                    field: 'merchantName',
                    title: '商户名称'
                },
                {
                    field: 'merchantAddress',
                    title: '商户地址'
                },
                {
                    field: 'name',
                    title: '姓名'
                },
                {
                    field: 'phone',
                    title: '手机号码'
                },
                {
                    field: 'cardNum',
                    title: '身份证号'
                },
                {
                    field: 'carditLimit',
                    title: '预授信额度'
                },
                {
                    field: 'headUrl',
                    title: '身份证头像面',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.imageView(row.headUrl, 300, 500);
                    }
                },
                {
                    field: 'badgeUrl',
                    title: '身份证国徽面',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.imageView(row.badgeUrl, 300, 500);
                    }
                },
                {
                    field: 'pictureUrl',
                    title: '办理合影',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.imageView(row.pictureUrl, 300, 500);
                    }
                },
                {
                    field: 'validity',
                    title: '有效期',
                    formatter: function (value, row, index) {
                        return value + '年'
                    }
                },
                {
                    field: 'preCreditUrl',
                    title: '授信卡路径',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.imageView(row.preCreditUrl, 300, 500);
                    }
                },
                {
                    field: 'deptName',
                    title: '所属机构'
                },
                {
                    field: 'userName',
                    title: '客户经理'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'beginDay',
                    title: '起始日期',
                    sortable: true
                },
                {
                    field: 'endDate',
                    title: '截止日期',
                    sortable: true
                },
                {
                    field: 'sts',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(stsDatas, value);

                    }
                }/*,
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }*/]
        };
        $.table.init(options);
    });

    function handOver() {
        var rows = $.table.selectFirstColumns();
        var url = prefix + '/priorHandOver/' + rows.join();
        var options = {
            title: '选择客户经理',
            width: 900,
            height: 700,
            url: url,
            callBack: doSubmit
        };
        $.modal.confirm("确认要移交选中的【" + rows.length + "】个数据吗?", function () {
            $.modal.openOptions(options);
        });

    }

    function doSubmit(index, layero) {
        var result = layero.find("iframe")[0].contentWindow.submitHandler();
        if (result) {
            setTimeout("$.table.refresh()", 600);
            $.modal.close(index);
            $.modal.msgSuccess("转交成功！");

        }
    }


    /* 选择机构树 */
    function selectDeptTree() {
        var treeId = $("#treeId").val();
        var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSub
        };
        $.modal.openOptions(options);
    }

    function doSub(index, layero) {
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }

    function reset() {
        $('#treeId').val('');
        $.form.reset();
    }

    function inquire() {
        $.table.search();
        var custType = $("#custType").val();
        if (custType == "1") {
            document.getElementById("handOver").style.visibility = "visible";
        } else {
            document.getElementById("handOver").style.visibility = "hidden";
        }

    }
</script>
</body>
</html>